package com.mmp.main.entity;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;

import com.mmp.common.util.SearchRequired;

/**
 * The persistent class for the user database table.
 *
 */

@Entity
@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u")
public class User implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	private Integer id;

	@Column(name = "user_name")
	@SearchRequired
	private String userName;

	@SearchRequired
	private String password;

	@OneToOne
	@JoinColumn(name = "employee_id")
	@SearchRequired(isObject = true, fields = { "status" })
	private Employee employee;
	
	@SearchRequired
	private Boolean status;


	public User() {
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Site getSite() {
		return employee.getSite();
	}

	public HospitalDepartment getDepartment() {
		return employee.getDepartment();
	}

	public String getName() {
		return employee.getName();
	}

	public String getMobile() {
		return employee.getMobile();
	}

	public String getJobTitle() {
		return employee.getJobTitle();
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public Integer getUserType() {
		return employee.getUserType();
	}

	public Boolean getMovingTeam() {
		return employee.getMovingTeam();
	}

	public Boolean getStatus() {
		return status && employee.getStatus();
	}
	
	public void setStatus(Boolean status) {
		this.status = status;
	}

}
